import { Status, BaseFilter } from './base';

// 组织联系信息
export interface OrganizationContactInfo {
  email?: string;
  phone?: string;
  address?: string;
  fax?: string;
  website?: string;
}

// 组织设置
export interface OrganizationSettings {
  maxUsers: number;
  maxSubOrganizations: number;
  features: string[];
  contactInfo?: OrganizationContactInfo;
  allowSubOrgCreation: boolean;
  inheritParentSettings: boolean;
}

// 组织实体
export interface Organization {
  id: string;
  tenantId: string;
  name: string;
  code: string;
  description?: string;
  parentId?: string;
  level: number;
  path: string; // 层级路径，如 "1/2/3"
  sort: number;
  status: Status;
  settings: OrganizationSettings;
  subscriptionPlanId?: string;
  managerUserId?: string;
  createdAt: string;
  updatedAt: string;
  createdBy?: string;
  updatedBy?: string;
  // 计算属性
  children?: Organization[];
  hasChildren?: boolean;
  userCount?: number;
  departmentCount?: number;
}

// 组织查询过滤器
export interface OrganizationFilter extends BaseFilter {
  tenantId?: string;
  parentId?: string;
  level?: number;
  managerUserId?: string;
  subscriptionPlanId?: string;
}

// 组织表单数据
export interface OrganizationFormData {
  name: string;
  code: string;
  description?: string;
  parentId?: string;
  status: Status;
  settings: Partial<OrganizationSettings>;
  subscriptionPlanId?: string;
  managerUserId?: string;
  sort?: number;
}

// 创建组织请求
export interface CreateOrganizationRequest extends OrganizationFormData {
  tenantId: string;
}

// 更新组织请求
export interface UpdateOrganizationRequest extends Partial<OrganizationFormData> {}

// 组织树节点
export interface OrganizationTreeNode {
  id: string;
  name: string;
  code: string;
  parentId?: string;
  level: number;
  status: Status;
  userCount: number;
  departmentCount: number;
  children: OrganizationTreeNode[];
  expanded?: boolean;
  selected?: boolean;
}

// 组织统计信息
export interface OrganizationStats {
  id: string;
  name: string;
  level: number;
  userCount: number;
  departmentCount: number;
  subOrganizationCount: number;
  directUserCount: number; // 直属用户数量
  totalUserCount: number; // 包含子组织用户数量
}